<%--
  Created by IntelliJ IDEA.
  User: John
  Date: 2019/10/29
  Time: 15:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>通用权限管理系统-登录</title>
    <link type="text/css" rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>

    <form id="loginForm" action="">
        用户名：<input type="text" name="username" /><br />
        密码：<input type="password" name="password" /> <br />
        <input type="submit">
    </form>

</body>
<script type="text/javascript" src="/static/layui/layui.js?date=456"></script>
<script type="text/javascript">

    layui.use(["jquery", "layer"], function(){
        var $ = layui.jquery
            ,layer = layui.layer;

        $("#loginForm").submit(function() {
            console.log("submit");
            $.getJSON("/login", $("#loginForm").serialize(), function(data){
                if(!data) {
                    layer.alert("登录失败");
                    return;
                }
                if(data.code != 200) {
                    layer.alert("登录失败," + data.msg);
                    return;
                }
                console.log("登录成功!");
                var url = data.data;
                location.href = url;
            });
            return false;
        });

    });
</script>
</html>
